package com.ty.day3;

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create 2023/11/8 18:12
 */
public class Task4 {
    public static void main(String[] args) {
        long x, count = 0, t;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        x = sc.nextLong();
        t = x;
        while (x > 1) {//大于1才可能由2组成
            if (x % 10 == 2) {//有一个2
                count++;//计数加一
            }
            x /= 10;
        }
        System.out.println(t + "中有" + count + "个2");
    }
}
